
package com.wu.dms.controller;

import com.wu.common.convertion.result.Result;
import com.wu.common.convertion.result.Results;
import com.wu.dms.dao.entity.Article;
import com.wu.dms.dto.ArticleUploadRequestDTO;
import com.wu.dms.service.ArticleService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("article")
public class ArticleController {
    private final ArticleService articleService;

    @PostMapping("/uploadMessage")
    public Result<Void> uploadArticle(@RequestBody ArticleUploadRequestDTO requestDTO) {
        System.out.println(requestDTO);
        return null;
    }

    @PostMapping("/uploadImage")
    public Result<Void> uploadImage(@RequestPart("file") MultipartFile file) {

        return Results.success(articleService.uploadImage(file));
    }

    @GetMapping("/all")
    public Result<List<Article>> findAll() {
        return Results.success(articleService.findAll());
    }


}

